<template>
  <div class="home">
    <div class="core">
      <el-card shadow="hover">
        <span>菜谱数</span>
        <span>{{coreData.cookbookNum}}</span>
      </el-card>
      <el-card shadow="hover">
        <span>菜品数</span>
        <span>{{coreData.foodNum}}</span>
      </el-card>
      <el-card shadow="hover">
        <span>订单数</span>
        <span>{{coreData.orderNum}}</span>
      </el-card>
      <el-card shadow="hover">
        <span>评价数</span>
        <span>{{coreData.commentNum}}</span>
      </el-card>
      <el-card shadow="hover">
        <span>用户数</span>
        <span>{{coreData.userNum}}</span>
      </el-card>
    </div>
    <div class="wx">
      <span class="wx-title">扫码登录小程序</span>
      <el-image class="wx-img" :src="wxUrl"></el-image>
    </div>
  </div>
</template>

<script>
export default {
  name: "Home",
  data () {
    return {
      wxUrl: require('../assets/images/wx.jpg'),
      coreData: {}
    }
  },
  methods:{
    loadCoreData () {
      this.$axios.get('/home/coreData').then(res => {
        if (res.code === 200) {
          this.coreData = res.data
        }
      })
    }
  },
  mounted() {
    this.loadCoreData()
  }
}
</script>

<style lang="scss" scoped>
  .home {
    width: 100%;
    .core {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 300px;
      box-sizing: border-box;
      padding: 50px 200px;
      .el-card {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 200px;
        height: 100px;
        font-weight: 100;
        font-size: 18px;
        span {
          margin: 0 10px;
        }
      }
    }
    .wx{
      width: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      .wx-title {
        font-weight: 100;
        font-size: 18px;
      }
      .wx-img {
        margin-top: 20px;
        width: 300px;
        height: 300px;
        overflow: hidden;
        border-radius: 6px;
      }
    }
  }
</style>